package com.h3c.gm.common.utils

import org.springframework.beans.BeanUtils
import com.google.common.collect.Lists;

/**
 * Created by d14287 on 2017/6/26.
 */
class ListUtils {
    static boolean isEmpty(List<?> list) {
        if (list == null || list.isEmpty()) {
            return true
        }
        return false
    }

    static boolean isNotEmpty(List<?> list) {
        if (list != null && list.size() > 0) {
            return true
        }
        return false
    }

    static List copyList(List<? extends Object> sourceList, Class targetClazz) throws Exception {
        if (sourceList == null || sourceList.isEmpty()) {
            return Lists.newArrayList()
        }
        List targetList = Lists.newArrayList()
        for (Object source : sourceList) {
            Object target = targetClazz.newInstance()
            BeanUtils.copyProperties(source, target)
            targetList.add(target)
        }
        return targetList
    }
}
